﻿using System;
using ETL.Common.Logging;
using ETL.DataAccess;
using ETL.Entity;

namespace ETL.Business.Handlers.ProjectTaskHandler
{
    class IsProjectTaskHasStartDate
    {
        private readonly ProjectTaskRepository _projectTaskRepository;

        public IsProjectTaskHasStartDate(ProjectTaskRepository projectTaskRepository)
        {
            _projectTaskRepository = projectTaskRepository;
        }

        public virtual bool Execute(int? projectId, int? categoryId, int? taskId)
        {
            project_tasks projectTasksData = null;

            // try to get from db
            try
            {
                projectTasksData = _projectTaskRepository.GetProjectTask(projectId, categoryId, taskId);
            }
            catch (Exception ex)
            {
                LogService.Service.Debug(ex);
            }

            if (projectTasksData != null && projectTasksData.t_start_date.HasValue)
            {
                return true;
            }
            return false;

        }
    }
}
